import re

# 匹配字符串
pattern = r'hello'
string = 'hello world'
match = re.search(pattern, string)
if match:
    print('Found match:', match.group())

# 替换字符串
pattern = r'hello'
replacement = 'world'
string = 'hello python'
new_string = re.sub(pattern, replacement, string)
print('New string:', new_string)

# 验证字符串

pattern = r'^\d{3}-\d{2}-\d{4}$'  # Social Security number pattern
string = '123-45-6789'
if re.match(pattern, string):
    print('Valid Social Security number')
else:
    print('Invalid Social Security number')
